<?php

/*
*	$version: 2008-1-3 17:05:51 beta 1.0
*	$id: io.php
*	$author: taoFeng
*	$mailto: font99@Gmail.com
*	$license: This is not a freeware
*/

if (!defined('IN_LEKO')) {header("HTTP/1.0 403 Forbidden");exit;}

final class Log extends Io {

	/*
	*	log::_log('想我吗');
	*	void _log (String $message,[enum $_type]);
	*/
	final public static function _log($_mes = '',$_type = 'error') {
		global $_G,$_D;

		if ($_type != 'error') $_type = 'event'; 
		$logTime = date("Y-m-d H:i:s");
		$logContent = $_G['phpSelf'] . ':' . $_mes . "\t" . $logTime . "\t" . $_G['onlineIp'];
		$logFile = FILE_ROOT . $_G['logDir'] . DIRECTORY_SEPARATOR .  date("Y-m") . DIRECTORY_SEPARATOR . $_G['curDate'] . "_$_type" . '.log';
		$logDir = dirname($logFile);
		if (!is_dir($logDir)) { @mkdir($logDir); }
		Io::_appendFile($logFile, $logContent . "\n");

		if ($_G['logDb'] === TRUE)
		{
			if ($_type != 'error') {$_type = 1;}else{$_type = 0;}
			$ip = explode('.',$_G['onlineIp']);
			$_D->sqlQuery("insert into {$_G['tablePrefix']}log (l_id,l_phpSelf,l_type,l_content,l_ip1,l_ip2,l_ip3,l_ip4,l_date) values 
			('NULL','{$_G['phpSelf']}','$_type','$_mes','$ip[0]','$ip[1]','$ip[2]','$ip[3]',NOW())");
		}

	}

}

?>
